package com.yunnuo.cmsmessage.controller;


import com.yunnuo.system.comm.controller.BaseController;
import com.yunnuo.system.comm.util.page.TableDataInfo;
import com.yunnuo.cmsmessage.service.IMessageService;
import com.yunnuo.system.users.entity.PageParams;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 消息推送
 *
 * @author 魏洪福（15064000912@163.com）
 * @create 2018-08-27-15:59
 */
@Controller
@RequestMapping("/cms/")
public class MessageController  extends BaseController {

    private String prefix = "cms";

    @Autowired
    private IMessageService messageService;



    @GetMapping()
    public String operlog()
    {
        return prefix + "/message";
    }

    /**
     * 分页查询
     * @param
     * @return
     */
    @RequiresPermissions("system:main:getMessage")
    @GetMapping("/getMessage")
    @ResponseBody
    public TableDataInfo getMessage(PageParams pageParams)
    {
        return  messageService.selectMessageByUserAndPageParams(pageParams,startPage(pageParams));
      /*  User user=ShiroUtils.getUser();
        model.addAttribute("messages",messageService.selectMessageByUser(user));*/
    }
    /**
     * 分页查询
     * @param pageParams
     * @return
     */
    @RequiresPermissions("system:main:list")
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(PageParams pageParams)
    {
        return  messageService.selectMessageByPageParams(pageParams,startPage(pageParams));
    }
}
